package org.rcgwt.client.ui.fields.theme;

import org.rcgwt.client.theme.CssStyle;

/**
 * The ValidatedTextField component Standard Theme.
 * 
 * @author Elian ORIOU
 * 
 */

public class StandardTheme implements ITheme {

	public static final StandardTheme INSTANCE = new StandardTheme();

	// Style Names
	private static final String MAIN_STYLE_CLASS = "rcgwt-validator";
	private static final String STYLE_ERROR_SUFFIX = "onerror";
	private static final String DEFAULT_TEXT_SUFFIX = "default-text";
	private static final String OTHER_TEXT_SUFFIX = "other-text";

	// CssStyle

	/***** VALIDATED TEXT FIELD STYLES *******/
	private CssStyle mainStyle;
	private CssStyle onErrorStyle;
	private CssStyle defaultTextStyle;
	private CssStyle otherTextStyle;

	/***** OTHER STYLES *****/

	protected StandardTheme() {
	}

	public static StandardTheme getInstance() {
		return INSTANCE;
	}

	public CssStyle getValidatedTextFieldMainStyle() {
		if (mainStyle == null) {
			mainStyle = CssStyle.create(MAIN_STYLE_CLASS);
		}
		return mainStyle;
	}

	public CssStyle getErrorStyle() {
		if (onErrorStyle == null) {
			onErrorStyle = getValidatedTextFieldMainStyle().addSuffix(
					STYLE_ERROR_SUFFIX);
		}
		return onErrorStyle;
	}

	public CssStyle getDefaultTextStyle() {
		if (defaultTextStyle == null) {
			defaultTextStyle = getValidatedTextFieldMainStyle().addSuffix(
					DEFAULT_TEXT_SUFFIX);
		}
		return defaultTextStyle;
	}

	public CssStyle getOtherTextStyle() {
		if (otherTextStyle == null) {
			otherTextStyle = getValidatedTextFieldMainStyle().addSuffix(
					OTHER_TEXT_SUFFIX);
		}
		return otherTextStyle;
	}
}
